Optional Quotations.f

Requires Stacks

\ TO DO: make it work when interpreting.

\ quotations should be executed using EXECUTE or CATCH
Only Forth Definitions

: does-:[  ( -- )
   does> @  ( xt )  compile,  postpone (else) here +bal ;

: >quote
   5 + code> ;

: :[] ( -- <name> )
   create here 0 , immediate does-:[
   :noname swap ! postpone r@ postpone >quote ;

: ;] ( -- )
   postpone exit  >resolve ; immediate

\ Use of a special stack allows us to store temporary values without cluttering the data stack.
\   The return stack, and therefore locals, are off-limits in quotation words, because they mess up the locals of calling routines.
256 stack: qstack

: >q  qstack push ;
: q>  qstack pop ;
: q@  qstack top @ ;

\ Get or compile the XT of the "executer" of a quote-word.
: [q]   state @ if postpone ['] code> >body @ postpone literal else ' code> >body @ then ; immediate
